package com.waiting.dynamic.proxy;

import java.lang.reflect.Proxy;

/**
 * @Description
 * @Author bjweitingting
 * @Date 2019/2/25
 **/
public class Main {
    //测试结果，代理调用
    public static void main(String args[]) {
        SuperInterface real = new SonClass();

        //生成代理对象
        SuperInterface proxySubject = (SuperInterface) Proxy.newProxyInstance(SuperInterface.class.getClassLoader(),
                new Class[]{SuperInterface.class},
                new MyInvocationHandler(real));

        //通过代理类调用方法
        proxySubject.test();
        proxySubject.speak();
    }
}
